//表格
import { http } from "@/utils/http";
import { type PaginationProps } from "@pureadmin/table";
import { baseUrlApi } from "./utils";
import { UserResult } from "./user";
//import { baseUrlApi } from "./utils";

type Result = {
  success: boolean;
  data?: {
    /** 列表数据 */
    list: Array<any>;
    /** 总条目数 */
    total?: number;
    /** 每页显示条目个数 */
    pageSize?: number;
    /** 当前页数 */
    currentPage?: number;
  };
};
type resultAPI = {
  isSuccess?: boolean;
  success?: boolean;
  msg?: string;
  pageInfo?: object;
  result?: Array<any>;
  onePage?: PaginationProps;
  data?: any;
};
/*
type ResultDept = {
  success: boolean;
  data?: Array<any>;
};
*/
/** 获取用户管理列表 */
export const getUserList = (data?: object) => {
  return http.request<Result>("post", "/user", { data });
};

/** 获取角色管理列表 */
export const getRoleListd = (data?: object) => {
  return http.request<resultAPI>("post", baseUrlApi("System/getSysRolesList"), {
    data
  });
};

export const saveRole = (data?: object) => {
  return http.request<resultAPI>("post", baseUrlApi("System/saveSysRoles"), {
    data
  });
};

export const delsysRows = (params?: object) => {
  return http.request<resultAPI>("post", baseUrlApi("System/delSysRoles"), {
    params
  });
};

export const loginByYunHua = (params?: object) => {
  return http.request<UserResult>("get", baseUrlApi("User/userLoginByYunHua"), {
    params
  });
};

export const uploadPic = (data?: object, type?: number) => {
  return http.request<resultAPI>(
    "post",
    baseUrlApi("System/uploadSysImage?fType=" + type),
    {
      data
    },
    {
      headers: {
        "Content-Type": "multipart/form-data"
      }
    }
  );
};

export const getWeiXinConfig = () => {
  return http.request<resultAPI>(
    "post",
    baseUrlApi("WebApi/getWeiXinConfigList")
  );
};

/*
export const saveWeiXinCon = (data?: object) => {
  console.log("data", data);
  return http.request<resultAPI>("post", baseUrlApi("WebApi/saveWeiXinConfig"), {
    data
  });
}
*/

export const saveWeiXinCon = (data?: object) => {
  return http.request<resultAPI>(
    "post",
    baseUrlApi("WebApi/saveWeiXinConfig"),
    {
      data
    }
  );
};

export const delWeiXinConfig = (params?: object) => {
  return http.request<resultAPI>("get", baseUrlApi("WebApi/delWeiXinConfig"), {
    params
  });
};
